export function getUserInfo() {
	return uni.getStorageSync("userinfo");
}

/**
 * 获取用户信息
 */
export function getUserMap() {
	return getUserInfo()?.userMap;
}

/**
 * 获取公司ID
 */
export function getCompanyId() {
	return getUserMap()?.companyId;
}

/**
 * 获取公司名称
 */
export function getCompanyName() {
	return getUserMap()?.companyName;
}

/**
 * 获取菜单信息
 */
export function getMenuData() {
	return getUserInfo()?.menuData;
}

/**
 * 获取应用列表
 */
export function getYingYong() {
	let menuData = getMenuData();
	for (var i = 0; i < menuData.length; i++) {
		if (menuData[i].cUuid == 'cd_yingyong') {
			return menuData[i].children;
		}
	}
}

/**
 * 获取指定code的菜单信息
 */
export function getMenuDataByCode(cAppFuncCode = "", menuList = []) {
	for (var i = 0; i < menuList.length; i++) {
		if (menuList[i].cAppFuncCode == cAppFuncCode) {
			return menuList[i].children;
		}
		if (menuList[i].children && menuList[i].children.length > 0) {
			let temp = getMenuDataByCode(cAppFuncCode, menuList[i].children);
			if (temp) {
				return temp;
			}
		}
	}
	return null;
}

export const genderMap = {
	0: '保密',
	1: '男',
	2: '女'
};

export function genderFromValue(value) {
	return genderMap[value] || '保密'
}